//package com.kedll.library.widget.wheelview.popupwindow;
//
//import android.content.Context;
//import android.content.DialogInterface;
//import android.view.View;
//import android.view.View.OnClickListener;
//import android.widget.TextView;
//
//import com.kedll.library.base.BaseDialog;
//import com.kedll.lvlang.R;
//import com.kedll.library.widget.wheelview.OnWheelScrollListener;
//import com.kedll.library.widget.wheelview.WheelView;
//import com.kedll.library.widget.wheelview.adapter.ArrayWheelAdapter;
//import com.kedll.library.widget.wheelview.adapter.NumericWheelAdapter;
//import com.kedll.utils.MyUtils;
//
//public class DatePickerDialog extends BaseDialog implements OnClickListener {
//    private WheelView yearView;
//    private WheelView monthView;
//    private WheelView dayView;
//    private WheelView hourView;
//    private WheelView minView;
//    private WheelView secView;
//    private TextView tv_finish;// 完成
//
//    private String time;// 当前选择的日期时间
//    private String contrasTime;// 需要对比的时间
//    private boolean isContrastMax;// 是否比较选中时间大于需要对比的时间
//    private OnSelectedDateListener l;// 选中日期接口
//
//    public DatePickerDialog(Context context) {
//        super(context);
//    }
//
//    protected DatePickerDialog(Context context, boolean cancelable, DialogInterface.OnCancelListener cancelListener) {
//        super(context, cancelable, cancelListener);
//    }
//
//    public DatePickerDialog(Context context, int theme) {
//        super(context, theme);
//    }
//
//    public DatePickerDialog(Context context, int theme, int width, int height) {
//        super(context, theme, width, height);
//    }
//
//
//    @Override
//    protected int initToolBar() {
//        return R.layout.pop_wheel_date_picker;
//    }
//
//    @Override
//    protected void initView(View view) {
//        time = "09:00";
////        birthday = startTime.substring(0, 4) + "-" + startTime.substring(4, 6)
////                + "-" + startTime.substring(6, 8);
////                + " " + startTime.substring(8, 10) + ":"
////                + startTime.substring(10, 12);
//        tv_finish = (TextView) view.findViewById(R.id.tv_finish);
//        yearView = (WheelView) view.findViewById(R.id.year);
//        yearView.setVisibility(View.GONE);
//        monthView = (WheelView) view.findViewById(R.id.month);
//        monthView.setVisibility(View.GONE);
//        dayView = (WheelView) view.findViewById(R.id.day);
//        hourView = (WheelView) view.findViewById(R.id.time);
//        minView = (WheelView) view.findViewById(R.id.min);
//        secView = (WheelView) view.findViewById(R.id.sec);
//        secView.setVisibility(View.GONE);
//    }
//
//    @Override
//    protected void setViewData() {
//        initWheel();
//    }
//
//    @Override
//    protected void initEvent() {
//        tv_finish.setOnClickListener(this);
//    }
//
//    private void initWheel() {
//        // TODO Auto-generated method stub
////        Calendar calendar = Calendar.getInstance();
////        curYear = calendar.get(Calendar.YEAR) - 100;
////        curMonth = calendar.get(Calendar.MONTH) + 1;
//
////        NumericWheelAdapter numericWheelAdapter1 = new NumericWheelAdapter(
////                context, curYear, curYear + 100);
////        numericWheelAdapter1.setLabel("年");
////        yearView.setViewAdapter(numericWheelAdapter1);
////        yearView.setCyclic(true);
////        yearView.addScrollingListener(scrollListener);
//
////        NumericWheelAdapter numericWheelAdapter2 = new NumericWheelAdapter(
////                context, 1, 12, "%02d");
////        numericWheelAdapter2.setLabel("月");
////        monthView.setViewAdapter(numericWheelAdapter2);
////        monthView.setCyclic(true);
////        monthView.addScrollingListener(scrollListener);
//
////        NumericWheelAdapter numericWheelAdapter3 = new NumericWheelAdapter(
////                context, 1, getDay(curYear, curMonth), "%02d");
//        String[] strings = {"上午", "下午"};
//        ArrayWheelAdapter arrayWheelAdapter = new ArrayWheelAdapter(getContext(), strings);
////        numericWheelAdapter3.setLabel("");
//        dayView.setViewAdapter(arrayWheelAdapter);
//        dayView.setCyclic(false);
//        dayView.setDrawLine(false);
//        dayView.addScrollingListener(scrollListener);
//
//        NumericWheelAdapter numericWheelAdapter4 = new NumericWheelAdapter(
//                getContext(), 1, 12, null);
//        numericWheelAdapter4.setLabel("");
//        hourView.setViewAdapter(numericWheelAdapter4);
//        hourView.setCyclic(true);
//        hourView.setDrawLine(false);
//        hourView.addScrollingListener(scrollListener);
//
//        NumericWheelAdapter numericWheelAdapter5 = new NumericWheelAdapter(
//                getContext(), 0, 59, null);
//        numericWheelAdapter5.setLabel("");
//        minView.setViewAdapter(numericWheelAdapter5);
//        minView.setCyclic(true);
//        minView.setDrawLine(false);
//        minView.addScrollingListener(scrollListener);
//
////        yearView.setCurrentItem(timeInt[0] - curYear);
////        monthView.setCurrentItem(timeInt[1] - 1);
////        dayView.setCurrentItem(timeInt[2] - 1);
////        hourView.setCurrentItem(timeInt[3]);
////        minView.setCurrentItem(timeInt[4]);
//        dayView.setCurrentItem(0);
//        hourView.setCurrentItem(8);
//        minView.setCurrentItem(0);
//    }
//
//    OnWheelScrollListener scrollListener = new OnWheelScrollListener() {
//        @Override
//        public void onScrollingStarted(WheelView wheel) {
//
//        }
//
//        @Override
//        public void onScrollingFinished(WheelView wheel) {
////            int n_year = yearView.getCurrentItem() + curYear;//
////            int n_month = monthView.getCurrentItem() + 1;//
////
////            initDay(n_year, n_month);
//            int dayPosition = dayView.getCurrentItem();
//            int hour = hourView.getCurrentItem() + 1;
//            if (dayPosition == 0) {
//                if (hour == 12) {
//                    hour = 0;
//                }
//            } else if (dayPosition == 1) {
//                if (hour != 12) {
//                    hour += 12;
//                }
//            }
//
//            time = String.format("%02d:%02d", hour, minView.getCurrentItem());
////                    .append((yearView.getCurrentItem() + curYear))
////                    .append("-")
////                    .append((monthView.getCurrentItem() + 1) < 10 ? "0"
////                            + (monthView.getCurrentItem() + 1) : (monthView
////                            .getCurrentItem() + 1))
////                    .append("-")
////                    .append(((dayView.getCurrentItem() + 1) < 10) ? "0"
////                            + (dayView.getCurrentItem() + 1) : (dayView
////                            .getCurrentItem() + 1)).toString();
////            birthday += " " + String.format("%02d", hourView.getCurrentItem())
////                    + ":" + String.format("%02d", minView.getCurrentItem());
//        }
//    };
//
//    /**
//     * 设置对比时间
//     *
//     * @param contrasTime
//     * @param isContrastMax 选择的时间是否大于等于对比时间
//     */
//    public void setContans(String contrasTime, boolean isContrastMax) {
//        this.contrasTime = contrasTime;
//        this.isContrastMax = isContrastMax;
//    }
//
//    private void initDay(int arg1, int arg2) {
//        NumericWheelAdapter numericWheelAdapter = new NumericWheelAdapter(
//                getContext(), 1, getDay(arg1, arg2), "%02d");
//        numericWheelAdapter.setLabel("日");
//        dayView.setViewAdapter(numericWheelAdapter);
//    }
//
//    private int getDay(int year, int month) {
//        int day = 30;
//        boolean flag = false;
//        switch (year % 4) {
//            case 0:
//                flag = true;
//                break;
//            default:
//                flag = false;
//                break;
//        }
//        switch (month) {
//            case 1:
//            case 3:
//            case 5:
//            case 7:
//            case 8:
//            case 10:
//            case 12:
//                day = 31;
//                break;
//            case 2:
//                day = flag ? 29 : 28;
//                break;
//            default:
//                day = 30;
//                break;
//        }
//        return day;
//    }
//
//    @Override
//    public void onClick(View v) {
//        // TODO Auto-generated method stub
//        switch (v.getId()) {
//            case R.id.tv_cancel:
//                break;
//
//            case R.id.tv_finish:
////                long time = System.currentTimeMillis();
////                long selectTime = MyUtils.getInstance().string2Date(
////                        "yyyy-MM-dd HH:mm:ss", birthday + ":00");
////                if (selectTime >= time) {
////                    MyUtils.getInstance().showToast(context, "设置时间必须小于当前时间");
////                    return;
////                }
//                if (!"--:--".equals(contrasTime)) {
//                    if (isContrastMax) {
//                        if (!MyUtils.isMin(time, contrasTime, ":")) {
//                            MyUtils.showToast(getContext(), "开始时间不得大于等于结束时间");
//                            return;
//                        }
//                    } else {
//                        if (!MyUtils.isMax(time, contrasTime, ":")) {
//                            MyUtils.showToast(getContext(), "结束时间不得小于等于开始时间");
//                            return;
//                        }
//                    }
//                }
//
//                if (l != null)
//                    l.onSelectedData(time);
//                break;
//
//            default:
//                break;
//        }
//        dismiss();
//    }
//
//    public void setOnSelectedDateListener(OnSelectedDateListener l) {
//        this.l = l;
//    }
//
//    /**
//     * 传递当前选择的日期时间
//     *
//     * @author dingrui
//     */
//    public interface OnSelectedDateListener {
//        public void onSelectedData(String time);
//    }
//}
